package uk.ac.cam.cl.projectcharlie2010.hardwaremove;

import java.io.IOException;
import java.io.OutputStream;
 
public class CommPortSender {
 
    static OutputStream out;
    
    public static void setWriterStream(OutputStream out) {
        CommPortSender.out = out;
    }
    
    public static void send(byte[] bytes) {
        try {
            System.out.println("SENDING: " + new String(bytes, 0, bytes.length));
            int i = 0;
            for(i=0;i<bytes.length;i++)
            {
            	out.write(bytes[i]);
            	out.flush();
            	Thread.sleep(10);
            	
            }
            // sending through serial port is simply writing into OutputStream
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
